
<form method="post" action="" enctype="application/x-www-form-urlencoded">
<?php
//echo $this->form;

$url = $this->urlbase.'/'.$this->modulo.'/'.$this->controller.'/';

$el = new Zend_Form_Element_Hidden('PER_ID',array('disableLoadDefaultDecorators' =>true));
$el->addDecorators(array(array('ViewHelper'),array('Errors')))
    ->setValue($this->obj['PER_ID'])
    ->addFilter('Int');
echo $el;

$nome = new Zend_Form_Element_Text('PER_NOME');
$nome->setLabel('Nome')
->setValue($this->obj['PER_NOME'])
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
echo $nome;

?> 
<dd>
<div class="content-edt-table">
<table id="tlist" class="tb_content">
    <tr>
        <th width="300">Módulo</th>
        <th width="20">Permissão</th>
        <th width="20">Adicionar</th>
        <th width="20">Editar</th>
        <th width="20">Deletar</th>
    </tr>
    
<?php

$obj = new Sistema_Model_DbTable_Modulos();
$row = $obj->fetchAll()->toArray();
$arr = array();

foreach($row as $key => $r)
{            
    $obj_prm = new Sistema_Model_DbTable_PermissaoHasModulo();
$row_prm = $obj_prm->fetchAll('PER_ID = '.$this->PER_ID.' and MOD_ID = '.$r['MOD_ID'])->toArray();
    $chk_mod = $chk_add = $chk_edt = $chk_del = '';
    foreach($row_prm as $r_prm){
       $chk_mod = 'checked="checked"';
       if($r_prm['MOD_ADD'] == 1) $chk_add = 'checked="checked"';
       if($r_prm['MOD_EDT'] == 1) $chk_edt = 'checked="checked"';
       if($r_prm['MOD_DEL'] == 1) $chk_del = 'checked="checked"';
    }
?> 
    <tr>
        <td><?php echo $r['MOD_NOME']; ?></td>
        <td style="text-align: center;"><input type="checkbox" <?php echo $chk_mod;?> value="<?php echo $r['MOD_ID']; ?>" name="MOD_ID[]"></td>
        <td style="text-align: center;"><input type="checkbox" <?php echo $chk_add;?> value="1" name="MOD_ADD[<?php echo $r['MOD_ID']; ?>]"></td>
        <td style="text-align: center;"><input type="checkbox" <?php echo $chk_edt;?> value="1" name="MOD_EDT[<?php echo $r['MOD_ID']; ?>]"></td>
        <td style="text-align: center;"><input type="checkbox" <?php echo $chk_del;?> value="1" name="MOD_DEL[<?php echo $r['MOD_ID']; ?>]"></td>
    </tr>
<?php
}

?> 
</table>
</div>  
</dd>
<?php


$btn = new Zend_Form_Element_Submit('submit',array('disableLoadDefaultDecorators' =>true));
$btn->addDecorators(array(array('ViewHelper'),array('Errors')));
$btn->setLabel('Gravar');
$btn->setAttrib('id', 'submitbutton');
$btn->setAttrib('class', 'btn-button btn-ok');
echo $btn;


$btn = new Zend_Form_Element_Button('Cancelar',array('disableLoadDefaultDecorators' =>true));
//$btn->addDecorators(array(array('ViewHelper'),array('Errors')));
$btn->setDecorators(array(array('Description', array('escape' => false, 'tag' => false))));
$btn->setDescription('<a href="'.$url.'" class="btn-button btn-cancel">Cancelar</a>');
$btn->setAttrib('id', 'btncancel');
$btn->setAttrib('class', 'btn-button btn-cancel');
echo $btn;
//$form->addElement($btn);

?>
</form>
